#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //这里我们完成了初步的控件搭建
    //接下来我们使用槽函数
    Button=new QPushButton(this);
    Button->setText("hello world");
    connect(Button,&QPushButton::clicked,this,&Widget::handleClick);
    Button->move(200,220);
//    connect(ui->pushButton,&QPushButton::clicked,this,&Widget::handleClick);
}

void Widget::handleClick()
{
    if(Button->text() == QString("hello world"))
    {
       Button->setText("hello QT");
    }
    else
    {
        Button->setText("hello world");
    }
}

Widget::~Widget()
{
    delete ui;
}

